package MULE.Model.Panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import MULE.Model.Logic.MenuLogic;
import MULE.Model.Logic.MuleDriver;

/**
 * Panel that shows game menu.
 * 
 * @author jstep
 */
public class MenuPanel extends JPanel {

	private JButton exitButton, saveButton, quitButton;

	/**
	 * Creates a new menu panel.
	 */
	public MenuPanel() {
		// TODO
		Dimension size = new Dimension(MuleDriver.WINDOW_WIDTH,
				MuleDriver.WINDOW_HEIGHT);
		this.setPreferredSize(size);
		this.setBackground(Color.black);
		exitButton = new JButton("Back to Game");
		exitButton.setActionCommand(MenuLogic.ActionCommand.EXIT_MENU
				.toString());
		this.add(exitButton);
		saveButton = new JButton("Save Game");
		saveButton.setActionCommand(MenuLogic.ActionCommand.SAVE_GAME
				.toString());
		this.add(saveButton);
		quitButton = new JButton("Quit Game");
		quitButton.setActionCommand(MenuLogic.ActionCommand.QUIT_GAME
				.toString());
		this.add(quitButton);
	}

	/**
	 * Adds the specified action listener to all of the menu panel's buttons.
	 * 
	 * @param listener
	 *            The panel buttons' action listener.
	 */
	public void addButtonListener(ActionListener listener) {
		exitButton.addActionListener(listener);
		saveButton.addActionListener(listener);
		quitButton.addActionListener(listener);
	}

	/**
	 * Sets whether or not the save button is enabled.
	 * 
	 * @param enabled
	 *            Whether or not the save button should be enabled.
	 */
	public void enableSaveButton(boolean enabled) {
		saveButton.setEnabled(enabled);
	}
}
